package com.sy.dao;

import com.sy.entity.CouponTemplate;
import org.apache.ibatis.annotations.*;

import java.util.List;


/**
 * @description: 码起 自动生成代码
 * @author: 小毛
 * @create: 2020-11-30 11:42:53
 */
public interface CouponTemplateDao {
    /*新增*/
    @Insert("insert into coupon_template (name,logo,intro,category,isgeneral,create_time,avlie_time,coupon_count,template_code,money,rule) values(#{name},#{logo},#{intro},#{category},#{isgeneral},now(),#{avlie_time},#{coupon_count},null,#{money},#{rule})")
    int insert(CouponTemplate couponTemplate);

    @Insert("insert into coupon_template (name,logo,intro,category,isgeneral,create_time,avlie_time,coupon_count,template_code,money,rule) values(#{name},#{logo},#{intro},#{category},#{isgeneral},now(),#{avlie_time},#{coupon_count},null,#{money},#{rule})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertId(CouponTemplate couponTemplate);

    /*删除*/
    @Delete("delete from coupon_template where id=#{id}")
    int deleteById(int id);
    /*查询全部*/
    @Select("select * from coupon_template")
    List<CouponTemplate> all();

    @Update("UPDATE coupon_template SET available = #{available} WHERE id = #{id}")
    void updateById(Integer id, Integer available);
}